home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 551-575 / disk_570 / gadtoolsbox / source / source.lha / WindowText.c < prev   
C/C++ Source or Header  |  1991-11-04  |  22KB  |  691 lines

  1. /*-- AutoRev header do NOT edit!
  2. *
  3. *   Program         :   WindowText.c
  4. *   Copyright       :   © Copyright 1991 Jaba Development
  5. *   Author          :   Jan van den Baard
  6. *   Creation Date   :   19-Oct-91
  7. *   Current version :   1.00
  8. *   Translator      :   DICE v2.6
  9. *
  10. *   REVISION HISTORY
  11. *
  12. *   Date          Version         Comment
  13. *   ---------     -------         ------------------------------------------
  14. *   19-Oct-91     1.00            Window text routines.
  15. *
  16. *-- REV_END --*/
  17.  
  18. #include "GTEd.h"
  19. #include "Protos.h"
  20.  
  21. /*
  22.  * --- External referenced data.
  23.  */
  24. extern ULONG                 Class;
  25. extern UWORD                 Code;
  26. extern struct TextAttr       Topaz80, MainFont;
  27. extern APTR                  MainVisualInfo;
  28. extern struct Screen        *MainScreen;
  29. extern struct Window        *MainWindow;
  30. extern struct Gadget        *Object;
  31. extern struct RastPort      *MainRP;
  32. extern struct MemoryChain   *Chain;
  33. extern struct IntuiText     *WindowTxt;
  34. extern UBYTE                 MainWindowTitle[80], MainScreenTitle[80];
  35. extern BOOL                  Saved;
  36.  
  37. /*
  38.  * --- Gadget ID's "Edit" window
  39.  */
  40. #define GD_ENTER            0
  41. #define GD_JAM1             1
  42. #define GD_JAM2             2
  43. #define GD_COMP             3
  44. #define GD_INVE             4
  45. #define GD_FPEN             5
  46. #define GD_BPEN             6
  47. #define GD_OK               7
  48. #define GD_CANCEL           8
  49.  
  50. /*
  51.  * --- Gadget ID's "Select" window
  52.  */
  53. #define GD_TEXTLIST         0
  54. #define GD_OKS              1
  55. #define GD_CANCELS          2
  56.  
  57. /*
  58.  * --- Module data.
  59.  */
  60. struct Window           *wt_Wnd   = NULL;
  61. struct Gadget           *wt_GList = NULL;
  62. struct Gadget           *wt_Gadgets[7];
  63. struct List              wt_Texts;
  64. BOOL                     wt_Jam1 = TRUE, wt_Jam2 = FALSE;
  65. BOOL                     wt_Comp = FALSE, wt_Inve = FALSE;
  66. UBYTE                    wt_FPen = 1, wt_BPen = 0;
  67.  
  68. WORD                     wt_Zoom[4];
  69.  
  70. UBYTE                   *wt_Edit = "Edit Window IntuiText:";
  71. UBYTE                   *wt_Get  = "Select Window IntuiText:";
  72.  
  73. struct TagItem           wt_nwTags[] = {
  74.     WA_Left,                0l,
  75.     WA_Top,                 0l,
  76.     WA_Width,               0l,
  77.     WA_Height,              0l,
  78.     WA_IDCMP,               IDCMP_CLOSEWINDOW | BUTTONIDCMP | STRINGIDCMP | CHECKBOXIDCMP | LISTVIEWIDCMP | IDCMP_VANILLAKEY | IDCMP_REFRESHWINDOW,
  79.     WA_Flags,               WFLG_DRAGBAR | WFLG_DEPTHGADGET| WFLG_CLOSEGADGET | WFLG_ACTIVATE | WFLG_RMBTRAP | WFLG_SMART_REFRESH,
  80.     WA_Gadgets,             0l,
  81.     WA_Title,               0l,
  82.     WA_AutoAdjust,          TRUE,
  83.     WA_Zoom,                (Tag)wt_Zoom,
  84.     TAG_DONE };
  85.  
  86. /*
  87.  * --- Put all IntuiText's in a list.
  88.  */
  89. long MakeTextList( void )
  90. {
  91.     struct ListViewNode *node;
  92.     struct IntuiText    *txt;
  93.  
  94.     NewList( &wt_Texts );
  95.  
  96.     if ( NOT( txt = WindowTxt )) return TRUE;
  97.  
  98.     while ( txt ) {
  99.         if ( node = MakeNode( txt->IText )) {
  100.             node->ln_UserData[0] = (ULONG)txt;
  101.             AddTail( &wt_Texts, ( struct Node * )node );
  102.             txt = txt->NextText;
  103.         } else {
  104.             MyRequest( "Oops...", "ARGHHH!", "Out of memory !" );
  105.             return FALSE;
  106.         }
  107.     }
  108.     return TRUE;
  109. }
  110.  
  111. /*
  112.  * --- Allocate an IntuiText structure.
  113.  */
  114. struct IntuiText *AddAText( void )
  115. {
  116.     struct IntuiText    *tmp, *text = 0l;
  117.  
  118.     if ( strlen((( struct StringInfo * )wt_Gadgets[ GD_ENTER ]->SpecialInfo )->Buffer )) {
  119.         tmp = WindowTxt;
  120.  
  121.         if ( tmp ) {
  122.             while ( tmp->NextText ) tmp = tmp->NextText;
  123.         }
  124.  
  125.         if ( text = ( struct IntuiText * )AllocItem( Chain, (long)sizeof( struct IntuiText ), MEMF_PUBLIC )) {
  126.             if ( text->IText = (UBYTE *)AllocItem( Chain, 80l, MEMF_PUBLIC )) {
  127.                 ChangeText( text );
  128.                 if ( tmp )  tmp->NextText = text;
  129.                 else        WindowTxt     = text;
  130.                 return( text );
  131.             }
  132.         }
  133.         MyRequest( "pompompidom", "puke", "Out of memory !" );
  134.  
  135.         if ( text ) {
  136.             if ( text->IText )  FreeItem( Chain, text->IText, 80l );
  137.             FreeItem( Chain, text, (long)sizeof( struct IntuiText ));
  138.         }
  139.     }
  140.     return( 0l );
  141. }
  142.  
  143. /*
  144.  * --- Change the IntuiText attributes.
  145.  */
  146. void ChangeText( struct IntuiText *text )
  147. {
  148.     if ( wt_Jam2 )  text->DrawMode  = JAM2;
  149.     else            text->DrawMode  = JAM1;
  150.     if ( wt_Comp )  text->DrawMode |= COMPLEMENT;
  151.     if ( wt_Inve )  text->DrawMode |= INVERSVID;
  152.  
  153.     text->FrontPen = wt_FPen;
  154.     text->BackPen  = wt_BPen;
  155.  
  156.     strcpy( text->IText, (( struct StringInfo * )wt_Gadgets[ GD_ENTER ]->SpecialInfo )->Buffer );
  157.  
  158.     Saved = FALSE;
  159. }
  160.  
  161. /*
  162.  * --- Place an IntuiText on the EditWindow.
  163.  */
  164. void PlaceText( struct IntuiText *txt )
  165. {
  166.     WORD    x, y, x1, y1;
  167.  
  168.     if ( txt ) {
  169.         GetMouseXY( &x, &y );
  170.         SetTitle( 0l );
  171.         UpdateCoords( 2l, x, y, 0, 0 );
  172.  
  173.         SetDrMd( MainRP, JAM1 | COMPLEMENT );
  174.  
  175.         Move( MainRP, x, y );
  176.         Text( MainRP, txt->IText, strlen( txt->IText ));
  177.  
  178.         while ( Code != SELECTDOWN ) {
  179.             while( ReadIMsg( MainWindow )) {
  180.                 if ( Code == SELECTDOWN ) break;
  181.                 if ( Class == IDCMP_MENUPICK ) {
  182.                     SetTitle( 0l );
  183.                     UpdateCoords( 2l, x, y, 0, 0 );
  184.                 }
  185.             }
  186.             GetMouseXY( &x1, &y1 );
  187.             if ( x1 != x || y1 != y ) {
  188.                 Move( MainRP, x, y );
  189.                 Text( MainRP, txt->IText, strlen( txt->IText ));
  190.                 x = x1;
  191.                 y = y1;
  192.                 Move( MainRP, x, y );
  193.                 Text( MainRP, txt->IText, strlen( txt->IText ));
  194.                 UpdateCoords( 2l, x, y, 0, 0 );
  195.             }
  196.         }
  197.  
  198.         Move( MainRP, x, y );
  199.         Text( MainRP, txt->IText, strlen( txt->IText ));
  200.  
  201.         txt->LeftEdge   =   x;
  202.         txt->TopEdge    =   y - MainScreen->RastPort.TxBaseline;
  203.  
  204.         SetWindowTitles( MainWindow, MainWindowTitle, MainScreenTitle );
  205.     }
  206. }
  207.  
  208. /*
  209.  * --- Deallocate all IntuiTexts.
  210.  */
  211. void DeleteTexts( void )
  212. {
  213.     struct IntuiText    *t1, *t2;
  214.  
  215.     if ( NOT( t1 = WindowTxt )) return;
  216.  
  217.     while ( t1 ) {
  218.         t2 = t1->NextText;
  219.         if ( t1->IText )    FreeItem( Chain, t1->IText, 80l );
  220.         FreeItem( Chain, t1, (long)sizeof( struct IntuiText ));
  221.         t1 = t2;
  222.     }
  223.     WindowTxt = 0l;
  224. }
  225.  
  226. /*
  227.  * --- Remove and deallocate an IntuiText from the list.
  228.  */
  229. void RemoveText( struct IntuiText *txt )
  230. {
  231.     struct IntuiText    *pred = 0l;
  232.  
  233.     if ( txt ) {
  234.         if ( txt != WindowTxt ) {
  235.             pred = WindowTxt;
  236.             while ( pred->NextText != txt ) pred = pred->NextText;
  237.         }
  238.  
  239.         if ( pred ) pred->NextText = txt->NextText;
  240.         else        WindowTxt      = txt->NextText;
  241.  
  242.         if ( txt->IText )   FreeItem( Chain, txt->IText, 80l );
  243.         FreeItem( Chain, txt, (long)sizeof( struct IntuiText ));
  244.     }
  245. }
  246.  
  247. /*
  248.  * --- Display the EditText requester.
  249.  */
  250. struct IntuiText *EditText( struct IntuiText *itxt )
  251. {
  252.     struct Gadget       *g;
  253.     struct IntuiText    *i = 0l;
  254.     struct NewGadget     ng;
  255.     BOOL                 running =  TRUE, OK = FALSE;
  256.     WORD                 l, t, w, h, btop, bleft;
  257.     UBYTE               *string = 0l;
  258.  
  259.     btop  = MainScreen->WBorTop + MainScreen->RastPort.TxHeight;
  260.     bleft = MainScreen->WBorLeft;
  261.  
  262.     w = bleft + MainScreen->WBorRight  + 300;
  263.     h = btop  + MainScreen->WBorBottom + 115;
  264.     l = (( MainScreen->Width  >> 1 ) - ( w >> 1 ));
  265.     t = (( MainScreen->Height >> 1 ) - ( h >> 1 ));
  266.  
  267.     wt_Zoom[0] = 0;
  268.     wt_Zoom[1] = btop;
  269.     wt_Zoom[2] = 200;
  270.     wt_Zoom[3] = btop;
  271.  
  272.     wt_nwTags[0].ti_Data = l;
  273.     wt_nwTags[1].ti_Data = t;
  274.     wt_nwTags[2].ti_Data = w;
  275.     wt_nwTags[3].ti_Data = h;
  276.  
  277.     wt_nwTags[10].ti_Data = (Tag)MainScreen;
  278.  
  279.     if (( MainScreen->Flags & CUSTOMSCREEN) == CUSTOMSCREEN )
  280.         wt_nwTags[10].ti_Tag  = WA_CustomScreen;
  281.     else if (( MainScreen->Flags & PUBLICSCREEN ) == PUBLICSCREEN )
  282.         wt_nwTags[10].ti_Tag  = WA_PubScreen;
  283.     else
  284.         wt_nwTags[10].ti_Tag  = TAG_DONE;
  285.  
  286.     if ( itxt ) {
  287.         if (( itxt->DrawMode & JAM2 ) == JAM2 )
  288.             { wt_Jam2 = TRUE; wt_Jam1 = FALSE; }
  289.         else
  290.             { wt_Jam2 = FALSE; wt_Jam1 = TRUE; }
  291.         if (( itxt->DrawMode & COMPLEMENT ) == COMPLEMENT )
  292.             wt_Comp = TRUE; else wt_Comp = FALSE;
  293.         if (( itxt->DrawMode & INVERSVID ) == INVERSVID )
  294.             wt_Inve = TRUE; else wt_Inve = FALSE;
  295.  
  296.         wt_FPen = itxt->FrontPen;
  297.         wt_BPen = itxt->BackPen;
  298.  
  299.         string = itxt->IText;
  300.     } else {
  301.         wt_Jam1 = TRUE;
  302.         wt_Jam2 = FALSE;
  303.         wt_Comp = FALSE;
  304.         wt_Inve = FALSE;
  305.         wt_FPen = 1;
  306.         wt_BPen = 0;
  307.     }
  308.  
  309.     if ( g = CreateContext( &wt_GList )) {
  310.  
  311.         ng.ng_LeftEdge      =   bleft + 8;
  312.         ng.ng_TopEdge       =   btop + 16;
  313.         ng.ng_Width         =   284;
  314.         ng.ng_Height        =   12;
  315.         ng.ng_GadgetText    =   "_Enter Text";
  316.         ng.ng_TextAttr      =   &Topaz80;
  317.         ng.ng_GadgetID      =   GD_ENTER;
  318.         ng.ng_Flags         =   PLACETEXT_ABOVE;
  319.         ng.ng_VisualInfo    =   MainVisualInfo;
  320.  
  321.         g = CreateGadget( STRING_KIND, g, &ng, GTST_String, (Tag)string, GTST_MaxChars, 80l, GT_Underscore, (Tag)'_', TAG_DONE );
  322.  
  323.         SetStringGadget( g );
  324.  
  325.         wt_Gadgets[ GD_ENTER ] = g;
  326.  
  327.         ng.ng_LeftEdge      =   bleft + 125;
  328.         ng.ng_TopEdge       =   btop + 32;
  329.         ng.ng_GadgetText    =   "JAM_1      ";
  330.         ng.ng_GadgetID      =   GD_JAM1;
  331.         ng.ng_Flags         =   PLACETEXT_LEFT;
  332.  
  333.         g = CreateGadget( CHECKBOX_KIND, g, &ng, GTCB_Checked, (Tag)wt_Jam1, GT_Underscore, (Tag)'_', TAG_DONE );
  334.  
  335.         wt_Gadgets[ GD_JAM1 ] = g;
  336.  
  337.         ng.ng_LeftEdge      =   bleft + 266;
  338.         ng.ng_GadgetText    =   "JAM_2     ";
  339.         ng.ng_GadgetID      =   GD_JAM2;
  340.  
  341.         g = CreateGadget( CHECKBOX_KIND, g, &ng, GTCB_Checked, (Tag)wt_Jam2, GT_Underscore, (Tag)'_', TAG_DONE );
  342.  
  343.         wt_Gadgets[ GD_JAM2 ] = g;
  344.  
  345.         ng.ng_TopEdge       =   btop + 46;
  346.         ng.ng_LeftEdge      =   bleft + 125;
  347.         ng.ng_GadgetText    =   "COM_PLEMENT";
  348.         ng.ng_GadgetID      =   GD_COMP;
  349.  
  350.         g = CreateGadget( CHECKBOX_KIND, g, &ng, GTCB_Checked, (Tag)wt_Comp, GT_Underscore, (Tag)'_', TAG_DONE );
  351.  
  352.         wt_Gadgets[ GD_COMP ] = g;
  353.  
  354.         ng.ng_LeftEdge      =   bleft + 266;
  355.         ng.ng_GadgetText    =   "_INVERSVID";
  356.         ng.ng_GadgetID      =   GD_INVE;
  357.  
  358.         g = CreateGadget( CHECKBOX_KIND, g, &ng, GTCB_Checked, (Tag)wt_Inve, GT_Underscore, (Tag)'_', TAG_DONE );
  359.  
  360.         wt_Gadgets[ GD_INVE ] = g;
  361.  
  362.         ng.ng_LeftEdge      =   bleft + 125;
  363.         ng.ng_TopEdge       =   btop + 60;
  364.         ng.ng_Width         =   167;
  365.         ng.ng_Height        =   15;
  366.         ng.ng_GadgetText    =   "FrontPen  ";
  367.         ng.ng_GadgetID      =   GD_FPEN;
  368.  
  369.         g = CreateGadget( PALETTE_KIND, g, &ng, GTPA_Depth, (Tag)MainScreen->BitMap.Depth, GTPA_Color, (Tag)wt_FPen, GTPA_IndicatorWidth, 27l, TAG_DONE );
  370.  
  371.         wt_Gadgets[ GD_FPEN ] = g;
  372.  
  373.         ng.ng_TopEdge       =   btop + 79;
  374.         ng.ng_GadgetText    =   "BackPen   ";
  375.         ng.ng_GadgetID      =   GD_BPEN;
  376.  
  377.         g = CreateGadget( PALETTE_KIND, g, &ng, GTPA_Depth, (Tag)MainScreen->BitMap.Depth, GTPA_Color, (Tag)wt_BPen, GTPA_IndicatorWidth, 27l, TAG_DONE );
  378.  
  379.         wt_Gadgets[ GD_BPEN ] = g;
  380.  
  381.         ng.ng_LeftEdge      =   bleft + 8;
  382.         ng.ng_TopEdge       =   btop + 98;
  383.         ng.ng_Width         =   90;
  384.         ng.ng_Height        =   13;
  385.         ng.ng_GadgetText    =   "_OK";
  386.         ng.ng_GadgetID      =   GD_OK;
  387.         ng.ng_Flags         =   PLACETEXT_IN;
  388.  
  389.         g = CreateGadget( BUTTON_KIND, g, &ng, GT_Underscore, (Tag)'_', TAG_DONE );
  390.  
  391.         ng.ng_LeftEdge      =   bleft + 201;
  392.         ng.ng_GadgetText    =   "_CANCEL";
  393.         ng.ng_GadgetID      =   GD_CANCEL;
  394.  
  395.         g = CreateGadget( BUTTON_KIND, g, &ng, GT_Underscore, (Tag)'_', TAG_DONE );
  396.  
  397.         if ( g ) {
  398.  
  399.             wt_nwTags[6].ti_Data = (Tag)wt_GList;
  400.             wt_nwTags[7].ti_Data = (Tag)wt_Edit;
  401.  
  402.             if ( wt_Wnd = OpenWindowTagList( NULL, wt_nwTags )) {
  403.  
  404.                 wt_Zoom[0] = l;
  405.                 wt_Zoom[1] = t;
  406.                 wt_Zoom[2] = w;
  407.                 wt_Zoom[3] = h;
  408.  
  409.                 GT_RefreshWindow( wt_Wnd, NULL );
  410.  
  411.                 do {
  412.                     WaitPort( wt_Wnd->UserPort );
  413.  
  414.                     while ( ReadIMsg( wt_Wnd )) {
  415.  
  416.                         switch ( Class ) {
  417.  
  418.                             case    IDCMP_REFRESHWINDOW:
  419.                                 GT_BeginRefresh( wt_Wnd );
  420.                                 GT_EndRefresh( wt_Wnd, TRUE );
  421.                                 break;
  422.  
  423.                             case    IDCMP_CLOSEWINDOW:
  424.                                 goto Cancel;
  425.                                 break;
  426.  
  427.                             case    IDCMP_VANILLAKEY:
  428.                                 switch ( Code ) {
  429.  
  430.                                     case    'e':
  431.                                         ActivateGadget( wt_Gadgets[ GD_ENTER ], wt_Wnd, 0l );
  432.                                         break;
  433.  
  434.                                     case    '1':
  435.                                         FlipFlop( wt_Wnd, wt_Gadgets, GD_JAM1, &wt_Jam1 );
  436.                                         goto Excl1;
  437.  
  438.                                     case    '2':
  439.                                         FlipFlop( wt_Wnd, wt_Gadgets, GD_JAM2, &wt_Jam2 );
  440.                                         goto Excl2;
  441.  
  442.                                     case    'p':
  443.                                         FlipFlop( wt_Wnd, wt_Gadgets, GD_COMP, &wt_Comp );
  444.                                         break;
  445.  
  446.                                     case    'i':
  447.                                         FlipFlop( wt_Wnd, wt_Gadgets, GD_INVE, &wt_Inve );
  448.                                         break;
  449.  
  450.                                     case    'c':
  451.                                         goto Cancel;
  452.  
  453.                                     case    'o':
  454.                                         goto Ok;
  455.                                 }
  456.                                 break;
  457.  
  458.                             case    IDCMP_GADGETUP:
  459.                                 switch ( Object->GadgetID ) {
  460.  
  461.                                     case    GD_JAM1:
  462.                                         FlipFlop( 0l, 0l, 0l, &wt_Jam1 );
  463.                                         Excl1:
  464.                                         if ( wt_Jam2 )
  465.                                             FlipFlop( wt_Wnd, wt_Gadgets, GD_JAM2, &wt_Jam2 );
  466.                                         break;
  467.  
  468.                                     case    GD_JAM2:
  469.                                         FlipFlop( 0l, 0l, 0l, &wt_Jam2 );
  470.                                         Excl2:
  471.                                         if ( wt_Jam1 )
  472.                                             FlipFlop( wt_Wnd, wt_Gadgets, GD_JAM1, &wt_Jam1 );
  473.                                         break;
  474.  
  475.                                     case    GD_COMP:
  476.                                         FlipFlop( 0l, 0l, 0l, &wt_Comp );
  477.                                         break;
  478.  
  479.                                     case    GD_INVE:
  480.                                         FlipFlop( 0l, 0l, 0l, &wt_Inve );
  481.                                         break;
  482.  
  483.                                     case    GD_FPEN:
  484.                                         wt_FPen = Code;
  485.                                         break;
  486.  
  487.                                     case    GD_BPEN:
  488.                                         wt_BPen = Code;
  489.                                         break;
  490.  
  491.                                     case    GD_CANCEL:
  492.                                         Cancel:
  493.                                         running = FALSE;
  494.                                         break;
  495.  
  496.                                     case    GD_OK:
  497.                                         Ok:
  498.                                         OK = TRUE;
  499.                                         running = FALSE;
  500.                                         break;
  501.                                 }
  502.                                 break;
  503.                         }
  504.                     }
  505.                 } while ( running );
  506.             }
  507.         }
  508.     }
  509.  
  510.     if ( OK && NOT itxt )   i = AddAText();
  511.     else if ( OK && itxt ) {
  512.         i = itxt;
  513.         ChangeText( i );
  514.     }
  515.  
  516.     if ( wt_Wnd )           CloseWindow( wt_Wnd );
  517.     if ( wt_GList )         FreeGadgets( wt_GList );
  518.  
  519.     wt_Wnd   = 0l;
  520.     wt_GList = 0l;
  521.  
  522.     ClearMsgPort( MainWindow->UserPort );
  523.  
  524.     return ( i );
  525. }
  526.  
  527. /*
  528.  * --- Display the SelectText requester.
  529.  */
  530. struct IntuiText *SelectText( void )
  531. {
  532.     struct Gadget       *g;
  533.     struct IntuiText    *i = 0l, *tmp;
  534.     struct ListViewNode *nde;
  535.     struct NewGadget     ng;
  536.     BOOL                 running =  TRUE, OK = FALSE;
  537.     WORD                 l, t, w, h, btop, bleft;
  538.     long                 tc = 0l;
  539.  
  540.     btop  = MainScreen->WBorTop + MainScreen->RastPort.TxHeight;
  541.     bleft = MainScreen->WBorLeft;
  542.  
  543.     w = bleft + MainScreen->WBorRight  + 300;
  544.     h = btop  + MainScreen->WBorBottom + 97;
  545.     l = (( MainScreen->Width  >> 1 ) - ( w >> 1 ));
  546.     t = (( MainScreen->Height >> 1 ) - ( h >> 1 ));
  547.  
  548.     wt_Zoom[0] = 0;
  549.     wt_Zoom[1] = btop;
  550.     wt_Zoom[2] = 200;
  551.     wt_Zoom[3] = btop;
  552.  
  553.     wt_nwTags[0].ti_Data = l;
  554.     wt_nwTags[1].ti_Data = t;
  555.     wt_nwTags[2].ti_Data = w;
  556.     wt_nwTags[3].ti_Data = h;
  557.  
  558.     wt_nwTags[10].ti_Data = (Tag)MainScreen;
  559.  
  560.     if (( MainScreen->Flags & CUSTOMSCREEN) == CUSTOMSCREEN )
  561.         wt_nwTags[10].ti_Tag  = WA_CustomScreen;
  562.     else if (( MainScreen->Flags & PUBLICSCREEN ) == PUBLICSCREEN )
  563.         wt_nwTags[10].ti_Tag  = WA_PubScreen;
  564.     else
  565.         wt_nwTags[10].ti_Tag  = TAG_DONE;
  566.  
  567.     if ( NOT( tmp = WindowTxt )) return( 0l );
  568.  
  569.     while ( tmp ) {
  570.         tc++;
  571.         tmp = tmp->NextText;
  572.     }
  573.  
  574.     if ( tc == 1 )
  575.         return( WindowTxt );
  576.  
  577.     if ( NOT MakeTextList())
  578.         return( 0l );
  579.  
  580.     if ( g = CreateContext( &wt_GList )) {
  581.  
  582.         ng.ng_LeftEdge      =   bleft + 8;
  583.         ng.ng_TopEdge       =   btop + 16;
  584.         ng.ng_Width         =   284;
  585.         ng.ng_Height        =   60;
  586.         ng.ng_GadgetText    =   "Available Texts:";
  587.         ng.ng_TextAttr      =   &Topaz80;
  588.         ng.ng_GadgetID      =   GD_TEXTLIST;
  589.         ng.ng_Flags         =   PLACETEXT_ABOVE;
  590.         ng.ng_VisualInfo    =   MainVisualInfo;
  591.  
  592.         g = CreateGadget( LISTVIEW_KIND, g, &ng, GTLV_Labels, (Tag)&wt_Texts, GTLV_ShowSelected, 0l, TAG_DONE );
  593.  
  594.         wt_Gadgets[ GD_TEXTLIST ] = g;
  595.  
  596.         ng.ng_LeftEdge      =   bleft + 8;
  597.         ng.ng_TopEdge       =   btop + 80;
  598.         ng.ng_Width         =   90;
  599.         ng.ng_Height        =   13;
  600.         ng.ng_GadgetText    =   "_OK";
  601.         ng.ng_GadgetID      =   GD_OKS;
  602.         ng.ng_Flags         =   PLACETEXT_IN;
  603.  
  604.         g = CreateGadget( BUTTON_KIND, g, &ng, GT_Underscore, (Tag)'_', TAG_DONE );
  605.  
  606.         ng.ng_LeftEdge      =   bleft + 201;
  607.         ng.ng_GadgetText    =   "_CANCEL";
  608.         ng.ng_GadgetID      =   GD_CANCELS;
  609.  
  610.         g = CreateGadget( BUTTON_KIND, g, &ng, GT_Underscore, (Tag)'_', TAG_DONE );
  611.  
  612.         if ( g ) {
  613.  
  614.             wt_nwTags[6].ti_Data = (Tag)wt_GList;
  615.             wt_nwTags[7].ti_Data = (Tag)wt_Get;
  616.  
  617.             if ( wt_Wnd = OpenWindowTagList( NULL, wt_nwTags )) {
  618.  
  619.                 wt_Zoom[0] = l;
  620.                 wt_Zoom[1] = t;
  621.                 wt_Zoom[2] = w;
  622.                 wt_Zoom[3] = h;
  623.  
  624.                 GT_RefreshWindow( wt_Wnd, NULL );
  625.  
  626.                 do {
  627.                     WaitPort( wt_Wnd->UserPort );
  628.  
  629.                     while ( ReadIMsg( wt_Wnd )) {
  630.  
  631.                         switch ( Class ) {
  632.  
  633.                             case    IDCMP_REFRESHWINDOW:
  634.                                 GT_BeginRefresh( wt_Wnd );
  635.                                 GT_EndRefresh( wt_Wnd, TRUE );
  636.                                 break;
  637.  
  638.                             case    IDCMP_CLOSEWINDOW:
  639.                                 goto Cancel;
  640.                                 break;
  641.  
  642.                             case    IDCMP_VANILLAKEY:
  643.                                 switch ( Code ) {
  644.  
  645.                                     case    'o':
  646.                                         goto Ok;
  647.  
  648.                                     case    'c':
  649.                                         goto Cancel;
  650.                                 }
  651.                                 break;
  652.  
  653.                             case    IDCMP_GADGETUP:
  654.                                 switch ( Object->GadgetID ) {
  655.  
  656.                                     case    GD_TEXTLIST:
  657.                                         nde = FindNode( &wt_Texts, Code );
  658.                                         i = ( struct IntuiText * )nde->ln_UserData[0];
  659.                                         break;
  660.  
  661.                                     case    GD_CANCELS:
  662.                                         Cancel:
  663.                                         i = 0l;
  664.                                         running = FALSE;
  665.                                         break;
  666.  
  667.                                     case    GD_OKS:
  668.                                         Ok:
  669.                                         OK = TRUE;
  670.                                         running = FALSE;
  671.                                         break;
  672.                                 }
  673.                                 break;
  674.                         }
  675.                     }
  676.                 } while ( running );
  677.             }
  678.         }
  679.     }
  680.  
  681.     if ( wt_Wnd )           CloseWindow( wt_Wnd );
  682.     if ( wt_GList )         FreeGadgets( wt_GList );
  683.  
  684.     wt_Wnd   = 0l;
  685.     wt_GList = 0l;
  686.  
  687.     ClearMsgPort( MainWindow->UserPort );
  688.  
  689.     return ( i );
  690. }
  691.